home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / misc / 80questions.lha / 80Questions / Source / 80Questions.b < prev   
Encoding:
Text File  |  1994-11-09  |  20.9 KB  |  754 lines

  1. 'Programming by Sean J. Miller
  2. 'Updated November 9, 1994.
  3. ' -------------------------------------------------------------------------
  4. DECLARE FUNCTION xRead& LIBRARY
  5. LONGINT offset&,samples_per_second&
  6. DECLARE SUB parse_sample(f$)
  7. DECLARE SUB play_sound(f$)
  8. DECLARE SUB TotalTime(TIME)
  9. DECLARE SUB Center(row,Text$)
  10. DECLARE SUB LineCenter(Text$)
  11. DECLARE SUB WordWrap(Text$)
  12. DECLARE SUB Wrong_Sound
  13. DECLARE SUB Right_Sound
  14. DECLARE SUB Lookback(most%,b%)
  15. '--------------------------------------------------------------------------
  16. CONST MAX=80
  17. DIM question$(MAX) SIZE 180, answer$(MAX) SIZE 180, gotit%(MAX), RightIFFs$(40) SIZE 90, WrongIFFs$(40) SIZE 90, mode%(9)
  18. #include <WBarg.h>
  19. ON WINDOW GOTO ending
  20. '--------------------------------------------------------------------------
  21.     a$="assign 80Questions: "+CHR$(34)+CHR$(34)
  22.     SYSTEM a$
  23.     OPEN "I",1,"RightIFFs"
  24.     rightsound%=0
  25.       WHILE NOT EOF(1) AND rightsound%<>40
  26.      ++rightsound%
  27.      LINE INPUT #1,RightIFFs$(rightsound%)
  28.       WEND
  29.     CLOSE #1
  30.  
  31.     OPEN "I",1,"WrongIFFs"
  32.     wrongsound%=0
  33.    WHILE NOT EOF(1) AND wrongsound%<>40
  34.       ++wrongsound%
  35.       LINE INPUT #1,WrongIFFs$(wrongsound%)
  36.    WEND
  37.     CLOSE #1
  38.  
  39.     OPEN "I",1,"80Questions.cfg"
  40.    IF EOF(1) = 0 THEN
  41.        INPUT #1,xm%,ym%,wm%,hm%,xg%,yg%,roro%,samps%,srsr%,talk%,dummy
  42.    ELSE
  43.        xm%=0:ym%=0:wm%=444:hm%=166:xg%=0:yg%=0:roro%=0:samps%=0:srsr%=0
  44.        talk%=0
  45.    END IF
  46.     IF samps%=1 AND (wrongsound%=0 OR rightsound%=0) THEN samps%=0
  47.     CLOSE #1
  48.  
  49. '--------------------------------------------------------------------
  50. randseed=(TIMER MOD 3)*TIMER:RANDOMIZE randseed
  51. mode%(7)=1:mode%(8)=2
  52. amtofques%=2:automark%=1:truemark%=1:fc%=0:bb%=1:cc%=1
  53. IF ARGCOUNT=1 THEN deffile$=ARG$(1)
  54. IF WBargcount=2 THEN deffile$=WBargPath$(1)+WBarg$(1)
  55. IF ARGCOUNT <> 1 AND WBargcount <> 2 THEN deffile$="No Test Selected"
  56. IF deffile$<>"No Test Selected" THEN GOSUB GetFile
  57. '--------------------------------------------------------------------
  58. starting:
  59.    b%=bb%:c%=cc%:repeatmark%=1:RIGHT%=0
  60.    IF reverse%=1 THEN b%=c%:c%=bb%:cc%=c%:bb%=b%:reverse%=0
  61.    FOR count%=1 TO MAX
  62.       gotit%(count%)=0
  63.    NEXT count%
  64. '--------------------------------------------------------------------
  65. MenuStart:
  66.    WINDOW ON
  67.    WINDOW 1,"80 Questions 1.0",(xg%,yg%)-(xg%+355,yg%+193),30
  68.    FONT "XEN",9
  69.    fontwidth%=WINDOW(12):fontheight%=WINDOW(13)
  70.    GADGET 1,1,deffile$,(10,5)-(330,25),2,1
  71.    IF roro%=0 THEN GADGET 2,1,"Original",(10,30)-(160,50),1,1
  72.    IF roro%=1 THEN GADGET 2,1,"Random  ",(10,30)-(160,50),1,1
  73.    IF srsr%=0 THEN GADGET 3,1,"Straight",(180,30)-(330,50),1,1
  74.    IF srsr%=1 THEN GADGET 3,1,"Reversed",(180,30)-(330,50),1,1
  75.    GADGET 4,1,"New     ",(10,55)-(160,75),1,1
  76.    GADGET 5,1,"Snapshot",(180,55)-(330,75),1,1         '..boolean
  77.    IF samps%=1 THEN GADGET 10,1,"Responses On ",(85,80)-(255,100),1,1
  78.    IF samps%=0 THEN GADGET 10,1,"Responses Off",(85,80)-(255,100),1,1
  79.    GADGET 6,1,amtofques%-1,(10,105)-(330,115),4             '.."from" horizontal slider
  80.    GADGET 7,1,amtofques%-1,(10,135)-(330,145),4             '.."to" horiz. slider
  81.    GADGET 8,1,"Begin   ",(10,155)-(160,175),1,1
  82.    GADGET 9,1,"Help    ",(180,155)-(330,175),1,1
  83.    LOCATE (INT(100/fontheight%)),3:PRINT"From:";b%
  84.    LOCATE (INT(134/fontheight%)),3:PRINT"To:";c%
  85.    WHILE -1
  86.      GADGET WAIT 0
  87.      GOSUB handle_gad
  88.    WEND
  89. handle_gad:
  90.    gad = GADGET(1)
  91.    IF gad=1 THEN
  92.        deffile$=CSTR(GADGET(2))
  93.        fc%=1
  94.        GOSUB GetFile
  95.    END IF
  96.    IF gad=2 THEN
  97.       IF roro%=0 THEN
  98.      roro%=1:GADGET CLOSE 2:GADGET 2,1,"Random",(10,30)-(160,50),1,1
  99.      RETURN
  100.       END IF
  101.       IF roro%=1 THEN
  102.      roro%=0:GADGET CLOSE 2:GADGET 2,1,"Original",(10,30)-(160,50),1,1
  103.      RETURN
  104.       END IF
  105.    END IF
  106.    IF gad=10 THEN
  107.       IF samps%=1 THEN
  108.       samps%=0:GADGET CLOSE 10
  109.       GADGET 10,1,"Responses Off",(85,80)-(255,100),1,1
  110.       RETURN
  111.       ELSE
  112.       IF wrongsound%>0 AND rightsound%>0 THEN
  113.      samps%=1:GADGET CLOSE 10
  114.      GADGET 10,1,"Responses On ",(85,80)-(255,100),1,1
  115.      RETURN
  116.       END IF
  117.       END IF
  118.    END IF
  119.    IF gad=3 THEN
  120.       IF srsr%=0 THEN
  121.      srsr%=1:GADGET CLOSE 3:GADGET 3,1,"Reversed",(180,30)-(330,50),1,1
  122.      RETURN
  123.       END IF
  124.       IF srsr%=1 THEN
  125.      srsr%=0
  126.      GADGET CLOSE 3:GADGET 3,1,"Straight",(180,30)-(330,50),1,1
  127.      RETURN
  128.       END IF
  129.    END IF
  130.    IF gad =5 THEN GOSUB Config
  131.       IF gad=6 THEN
  132.      LOCATE (INT(100/fontheight%)),3:PRINT SPC(10);
  133.      LOCATE (INT(100/fontheight%)),3
  134.      PRINT"From:";GADGET(3)+1;"   ";:b%=GADGET(3)+1
  135.       END IF
  136.    IF gad=7 THEN
  137.       LOCATE (INT(134/fontheight%)),3:PRINT SPC(10);
  138.       LOCATE (INT(134/fontheight%)),3
  139.       PRINT"To:";GADGET(3)+1;"   ";:c%=GADGET(3)+1
  140.    END IF
  141.    IF gad =8 AND deffile$<>"No Test Selected" THEN
  142.       windo&=WINDOW(7):xg%=PEEKW(windo&+4):yg%=PEEKW(windo&+6):reverse%=0
  143.       GOSUB CloseMenu
  144.       GOTO OrderGetter
  145.    END IF
  146.    IF gad =9 THEN GOSUB Help
  147.    IF gad =4 THEN GOSUB filechange
  148. RETURN
  149. '--------------------------------------------------------------------------
  150. OrderGetter:
  151.    WINDOW STOP
  152.    markadv%=1:bb%=b%:cc%=c%
  153.    WINDOW 1,deffile$,(xm%,ym%)-(xm%+wm%,ym%+hm%),23
  154.    FONT "XEN",9
  155.    windo&=WINDOW(7)):wm%=PEEKW(windo&+8):centerseed%=(wm%/WINDOW(12))
  156.    IF roro%=0 THEN
  157.       GOTO StraightOrder
  158.    ELSE
  159.       GOTO RandomOrder
  160.    END IF
  161. '-------------------------------------------------------------------------
  162. RandomOrder:
  163.    IF b%>c% THEN bb%=b%:b%=c%:c%=bb%:cc%=c%:bb%=b%:reverse%=1
  164.    CLS:COLOR 2,4:Center(5,"Randomizing the test"):COLOR 1,0
  165.    a$=".":a%=7
  166.    num% = INT(RND * (c%-b%+1)) + b%
  167.    FOR count% = b% TO c%
  168.       REPEAT
  169.       same%=0
  170.       num% = INT(RND * (c%-b%+1)) + b%
  171.       FOR check% = b% TO count%
  172.      IF num% = gotit%(check%) THEN same%=1
  173.       NEXT check%
  174.       UNTIL same%=0
  175.       IF LEN(a$)=(centerseed%-15) THEN
  176.      a$="."
  177.      a%=8
  178.       END IF
  179.       Center(a%,a$):a$=a$+".":gotit%(count%) = num%
  180.    NEXT count%
  181.    GOTO Test
  182. '-------------------------------------------------------------------------
  183. StraightOrder:
  184.    IF b%>c% THEN
  185.     reverse%=1:bb%=b%:b%=c%:c%=bb%:cc%=c%:bb%=b%
  186.    END IF
  187.    IF reverse%=1 THEN
  188.       FOR count%=b% TO c%
  189.      gotit%(count%)=c%-count%+1
  190.       NEXT count%
  191.    ELSE
  192.       FOR count%=b% TO c%
  193.      gotit%(count%)=count%
  194.       NEXT count%
  195.    END IF
  196.    GOTO Test
  197. '-------------------------------------------------------------------------
  198. Config:
  199.    WINDOW 2,"80 Questions 1.0 (November 1994)",(xm%,ym%)-(xm%+wm%,ym%+hm%),23
  200.    WINDOW OUTPUT 2:COLOR 1,0:CLS:a$=""
  201.    FONT "XEN",9
  202.    CALL Center(0, "Press [s] to save settings or [c] to cancel.")
  203.    WHILE a$<>"s"
  204.       a$=INKEY$
  205.       IF a$="c" THEN
  206.          WINDOW CLOSE 2
  207.          RETURN
  208.       END IF
  209.       IF a$<>"" AND samps%=1 THEN CALL Right_Sound
  210.    WEND
  211.    windo&=WINDOW(7)
  212.    xm%=PEEKW(windo&+4):ym%=PEEKW(windo&+6)
  213.    wm%=PEEKW(windo&+8):hm%=PEEKW(windo&+10)
  214.    CLS
  215.    Center(5,"Saving data to your config file...")
  216.    WINDOW OUTPUT 1:windo&=WINDOW(7):xg%=PEEKW(windo&+4):yg%=PEEKW(windo&+6)
  217.    OPEN "O",#1,"80Questions:80Questions.cfg"
  218.    WRITE #1,xm%,ym%,wm%,hm%,xg%,yg%,roro%,samps%,srsr%,talk%
  219.    CLOSE #1
  220.    PRINT:WINDOW CLOSE 2
  221.    RETURN
  222. '-------------------------------------------------------------------------
  223. Test:
  224.    CLS
  225.    COLOR 2,4
  226.    LineCenter("You have the following options selected:")
  227.    PRINT
  228.    COLOR 2,0
  229.    IF talk%=1  THEN CALL LineCenter("Amiga Speech Synthesis")
  230.    IF samps%=1 THEN CALL LineCenter("Responses")
  231.    PRINT
  232.    COLOR 2,4
  233.    LineCenter("Type '-help' (including the dash) as an answer")
  234.    LineCenter("to see how to change these options.")
  235.    PRINT
  236.    LineCenter("Press any key to begin test.")
  237.    COLOR 1,0
  238.    REPEAT SLEEP UNTIL INKEY$<>""
  239.    timeone=TIMER
  240.    FOR count% = b% TO c%
  241. 5  CLS
  242.    COLOR 3,0
  243.    PRINT"Question";(count%-b%+1);"out of";(c%-b%+1);".",
  244.    IF automark%=0 THEN
  245.       PRINT"Automarking is off."
  246.    ELSE
  247.       PRINT"Automarking is on."
  248.    END IF
  249.    IF (count%-b%)>0 THEN PRINT"Current percentage:  ",INT(RIGHT%/(count%-b%)*100);"%",
  250.    PRINT"(";RIGHT%;"for";(count%-b%);")"
  251.    COLOR 1,0
  252.    GOSUB Setup
  253.    COLOR 2,0
  254.    INPUT yourans$
  255.    IF yourans$ = "-back" THEN
  256.     CALL Lookback(count%,b%)
  257.     GOTO 5
  258.    END IF
  259.    IF yourans$ = "-quit" THEN GOTO Stopping
  260.    IF yourans$ = "-responses off" THEN
  261.        samps%=0
  262.        GOTO 5
  263.    END IF
  264.    IF yourans$ = "-talk off" THEN
  265.        talk%=0
  266.        GOTO 5
  267.    END IF
  268.    IF yourans$ = "-help" THEN
  269.        GOSUB Help
  270.        GOTO 5
  271.    END IF
  272.    IF yourans$ = "-talk on" THEN
  273.       talk%=1
  274.       GOTO 5
  275.    END IF
  276.    IF yourans$ = "-responses on" THEN
  277.        IF (wrongsound%=0 OR rightsound%=0) THEN GOTO 5
  278.        samps%=1
  279.        GOTO 5
  280.    END IF
  281.    num%=gotit%(count%)
  282.    IF answer$(num%) = yourans$ AND srsr%=0 THEN
  283.       GOSUB RightRoutine
  284.       GOTO 20
  285.    END IF
  286.    IF question$(num%)=yourans$ AND srsr%=1 THEN
  287.       GOSUB RightRoutine
  288.       GOTO 20
  289.    END IF
  290.    COLOR 1,0
  291.    PRINT
  292.    PRINT "Wrong, press:"
  293.    PRINT "               a) to try again."
  294.    PRINT "               m) to take your error like a man."
  295. 10 REPEAT
  296.     SLEEP
  297.     a$ = INKEY$
  298.    UNTIL a$<>""
  299.  
  300.    IF a$ = "" THEN 10
  301.    IF a$ = "a" THEN 5
  302.    IF a$ = "m" THEN
  303.       GOSUB WrongRoutine
  304.       GOTO 20
  305.    END IF
  306.    IF a$<>"" THEN BEEP
  307.    GOTO 10
  308. 20  NEXT count%
  309.    GOTO Stopping
  310. '-------------------------------------------------------------------------
  311. Stopping:
  312.    TIME = TIMER - timeone
  313.    CALL TotalTime(TIME)
  314.    CLS
  315.    COLOR 1,0
  316.    LOCATE 2, 1
  317.    PRINT "Total time:  ";hours%;"hours";minutes%;"minutes and";INT(seconds%);"seconds."
  318.    LOCATE 4, 1
  319.    PRINT "You got"; RIGHT%; "correct out of"; (count% - b%); "."
  320.    IF (count% - b%) <= 0 THEN
  321.    Center(6, "I hope you can do more questions for the test!")
  322.    GOTO StartOver
  323.    END IF
  324.    PRINT "This is"; (RIGHT% / (count% - b%) * 100); "percent."
  325.    IF markadv%>1 THEN
  326.    PRINT "You also have";(markadv%-1);"incorrect answer(s) marked for repeating."
  327.    ELSE
  328.    repeatmark%=1
  329.    END IF
  330.    PRINT
  331.    GOTO StartOver
  332. '-------------------------------------------------------------------------
  333. StartOver:
  334.    COLOR 2,4
  335.    LineCenter("[m] Main menu.                       ")
  336.    IF repeatmark%=1 THEN
  337.    CALL LineCenter("[r] Repeat last test.                ")
  338.    ELSE
  339.    CALL LineCenter("[w] Repeat only the marked questions.")
  340.    END IF
  341.    LineCenter("[e] Repeat entire test.              ")
  342.    LineCenter("[q] Quit.                            ")
  343.    COLOR 1,0
  344. 40   REPEAT
  345.       SLEEP
  346.       a$ = INKEY$
  347.      UNTIL a$<>""
  348.    IF a$="w" AND markadv%>1 THEN
  349.    b%=1:c%=markadv%-1:markadv%=1:RIGHT%=0
  350.    automark%=0
  351.    GOTO Test
  352.    END IF
  353.    IF a$="e" THEN
  354.    repeatmark%=0
  355.    a$="r"
  356.    END IF
  357.      IF a$ = "m" THEN
  358.      windo&=WINDOW(7)
  359.      xm%=PEEKW(windo&+4):ym%=PEEKW(windo&+6)
  360.      wm%=PEEKW(windo&+8):hm%=PEEKW(windo&+10)
  361.      automark%=truemark%:amtofques%=oldamt%
  362.    WINDOW CLOSE 1
  363.    GOTO starting
  364.    END IF
  365.    IF a$ = "q" THEN
  366.        WINDOW CLOSE 1
  367.        SYSTEM "assign 80Questions:"
  368.    STOP
  369.    END IF
  370.    IF a$ = "r" THEN
  371.    RIGHT%=0
  372.    IF repeatmark%=1 THEN GOTO Test
  373.    b%=bb%:c%=cc%:automark%=truemark%
  374.    FOR count%=1 TO MAX
  375.       gotit%(count%)=0
  376.    NEXT count%
  377.    GOTO OrderGetter
  378.    END IF
  379.    IF a$<>"" THEN BEEP
  380.    GOTO 40
  381. '-------------------------------------------------------------------------
  382. Setup:
  383.    LOCATE 4, 1
  384.    IF srsr%=0 THEN
  385.        Printques$ = question$(gotit%(count%))
  386.    ELSE
  387.        Printques$ = answer$(gotit%(count%))
  388.    END IF
  389.    IF talk%=1 THEN SAY TRANSLATE$(Printques$),mode%
  390.    WordWrap(PRINTques$)
  391.    RETURN
  392. '-------------------------------------------------------------------------
  393. RightRoutine:
  394.     IF samps%=1 THEN CALL Right_Sound
  395.     RIGHT% = RIGHT% + 1
  396.     RETURN
  397. '-------------------------------------------------------------------------
  398. WrongRoutine:
  399.     CLS
  400.     Center(2,"Wrong!  The answer was supposed to be:")
  401.     COLOR 2,3
  402.     IF srsr%=0 THEN
  403.    text$=answer$(num%)
  404.    WordWrap(text$)
  405.     ELSE
  406.    text$=question$(num%)
  407.    WordWrap(text$)
  408.     END IF
  409.     COLOR 1,0
  410.     PRINT
  411.     LineCenter("You had put:")
  412.     COLOR 1,2
  413.     WordWrap(yourans$)
  414.     COLOR 1,0
  415.     PRINT
  416.     IF automark%=0 THEN CALL LineCenter("m) Mark for repeating later.         ")
  417.     LineCenter("t) Make it correct since it was an   ")
  418.     LineCenter("   insignificant typo.               ")
  419.     LineCenter("<or>")
  420.     LineCenter("Press any key to continue.")
  421.    REPEAT
  422.        SLEEP
  423.        a$=INKEY$
  424.    UNTIL a$<>""
  425.    IF a$ = "t" THEN GOSUB RightRoutine
  426.    IF a$ = "m" AND automark%=0 THEN
  427.       gotit%(markadv%)=gotit%(count%)
  428.       markadv%=markadv%+1
  429.       repeatmark%=0
  430.       CALL LineCenter("(Marked!)")
  431.    END IF
  432.    IF automark%=1 AND a$<>"t" THEN
  433.        gotit%(markadv%)=gotit%(count%)
  434.        repeatmark%=0
  435.        markadv%=markadv%+1
  436.    END IF
  437.    IF samps%=1 AND a$<>"t" AND a$<>"m" THEN CALL Wrong_Sound
  438. RETURN
  439. '-------------------------------------------------------------------------
  440. FileChange:
  441.    fc%=1
  442.    path$=FILEBOX$("New Test")
  443.    IF path$="" THEN GOTO outpath
  444.    deffile$=path$
  445. GetFile:
  446.    cdir$=deffile$:pe%=0
  447.    REPEAT
  448.        IF MID$(deffile$,LEN(deffile$)-pe%,1)="/" OR MID$(deffile$,LEN(deffile$)-pe%,1)=":" THEN cdir$=LEFT$(deffile$,(LEN(deffile$)-pe%))
  449.        ++pe%
  450.    UNTIL (pe%=LEN(deffile$)+1) OR cdir$<>deffile$
  451.    IF cdir$<>deffile$ THEN CHDIR cdir$
  452.    amtofques% = 1
  453.    OPEN "I",1,deffile$
  454.    IF EOF(1)<>0 THEN
  455.        deffile$="No Test Selected"
  456.        amtofques%=2
  457.        CLOSE 1
  458.        RETURN
  459.    END IF
  460.    b%=1:c%=1:bb%=1:cc%=1:b$=".":a%=5
  461.    WINDOW 2,"80 Questions",(xg%+60,yg%)-(xg%+296,yg%+100),22
  462.    WINDOW OUTPUT 2
  463.    FONT "XEN",9
  464.    center (1,"Programming by")
  465.    center (2,"Sean J. Miller")
  466.    center(4,"Getting the test...")
  467.    WHILE EOF(1)=0 AND (amtofques%<=MAX)
  468.        a$="":q$=""
  469.        WHILE q$="" AND EOF(1)=0
  470.         LINE INPUT #1, q$
  471.        WEND
  472.        WHILE a$="" AND EOF(1)=0
  473.         LINE INPUT #1, a$
  474.        WEND
  475.        b$=b$+"."
  476.        IF LEN(b$)>((220/WINDOW(12))-5) THEN
  477.         b$=".":a%=a%+1
  478.        END IF
  479.        center(a%,b$)
  480.        question$(amtofques%) = LEFT$ (q$,179)
  481.        answer$(amtofques%) = LEFT$(a$,179)
  482.        if q$<> "" THEN amtofques% = amtofques% + 1
  483.    WEND
  484. GotData:
  485.    amtofques% = amtofques% - 1:oldamt%=amtofques%
  486.    IF fc%=1 THEN
  487.       fc%=0
  488.       WINDOW OUTPUT 1
  489.       GADGET CLOSE 1:GADGET CLOSE 6:GADGET CLOSE 7
  490.       GADGET 1,1,deffile$,(10,5)-(330,25),2,1
  491.       GADGET 6,1,amtofques%-1,(10,105)-(330,115),4
  492.       GADGET 7,1,amtofques%-1,(10,135)-(330,145),4
  493.       LOCATE (INT(100/fontheight%)),3:PRINT SPC(10);
  494.       LOCATE (INT(100/fontheight%)),3:PRINT"From:";b%;"   ";
  495.       LOCATE (INT(134/fontheight%)),3:PRINT SPC(10);
  496.       LOCATE (INT(134/fontheight%)),3:PRINT"To:";c%;"   ";
  497.    END IF
  498.    WINDOW CLOSE 2
  499.    WINDOW OUTPUT 1
  500. outpath:
  501.    CLOSE 1
  502.    RETURN
  503. CloseMenu:
  504.    FOR count%=1 TO 10
  505.    GADGET CLOSE count%
  506.    NEXT count%
  507.    WINDOW CLOSE 1
  508. RETURN
  509. '-------------------------------------------------------------------------
  510. Help:
  511.    WINDOW STOP
  512.    WINDOW 2,"80 Questions 1.0 (November 1994) by Sean J. Miller",(xm%,ym%)-(xm%+wm%,ym%+hm%),23
  513.    FONT "XEN",9
  514.    COLOR 2,0
  515.    CLS
  516.    Center(2,"HELP")
  517.    Center(4,"--To make a test, just go to any text editor or wordprocessor ")
  518.    Center(5,"  and type in your questions and answers consecutively in     ")
  519.    Center(6,"  the order you choose.  Use a hard return at the end of each ")
  520.    Center(7,"  question and answer and do not allow word wrapping.         ")
  521.    Center(8,"  Also, be sure to export it as an ASCII file which is usually")
  522.    Center(9,"  a standard option on most text editors and word processors. ")
  523.    Center(11,"--Questions and answers must not be greater than 180 letters. ")
  524.    REPEAT SLEEP UNTIL INKEY$<>""
  525.    CLS
  526.    Center(2, "--Only 80 questions are allowed due to memory limits.      ")
  527.    Center(4, "--To start a test click once on the test's icon, hold down ")
  528.    Center(5, "  shift, and then double click on the 80Questions' icon.   ")
  529.    Center(7, "--To take a different test without ending the program,     ")
  530.    Center(8, "  select the 'NEW' gadget and find the test's path.        ")
  531.    Center(10, "--Automarking automatically sets aside missed questions so ")
  532.    Center(11, "  you can repeat them later.  It is turned off when repeat-")
  533.    Center(12, "  ing the missed questions so you can mark new errors.     ")
  534.    REPEAT SLEEP UNTIL INKEY$<>""
  535.    CLS
  536.    Center(2, "The following actions can be done during the test by typing ")
  537.    Center(3, "in the appropriate keyword:                                 ")
  538.    Center(4, "  Keyword                   Action                          ")
  539.    Center(5, "  -------                   ------                          ")
  540.    Center(6, "  -quit                     Ends test at the previous       ")
  541.    Center(7, "                            question.                       ")
  542.    Center(9, "  -responses on            *Turns the sampled responses on. ")
  543.    Center(11, "  -responses off           Turns the sampled responses off. ")
  544.    Center(13, "  * You must have at least ONE path of a sample in the files")
  545.    center(14, "    <rightiffs> and <wrongiffs>.  See docs for more info.   ")
  546.    REPEAT SLEEP UNTIL INKEY$<>""
  547.    CLS
  548.    Center(2, "  Keyword                   Action                          ")
  549.    Center(3, "  -------                   ------                          ")
  550.    Center(4, "  -talk on                  Turns the Amiga speech on.      ")
  551.    Center(5, "  -talk off                 Turns the Amiga speech off.     ")
  552.    Center(7, "  -back                     Allows one to view previous     ")
  553.    Center(8, "                            questions.                      ")
  554.    REPEAT SLEEP UNTIL INKEY$<>""
  555.    WINDOW CLOSE 2
  556.    WINDOW ON
  557. RETURN
  558.  
  559. SUB Center(row, Text$)
  560.    fontwidth%=WINDOW(12):fontheight%=WINDOW(13)
  561.    windo&=WINDOW(7):wm%=PEEKW(windo&+8)
  562.    IF row=0 THEN
  563.       hm%=PEEKW(windo&+10)
  564.       row=INT((hm%/fontheight%)/2)-1
  565.    END IF
  566.    Col% = INT((wm%/fontwidth%) / 2)
  567.    LOCATE row, INT(Col% - (LEN(Text$) / 2))
  568.    PRINT Text$
  569. END SUB
  570. SUB LineCenter(Text$)
  571.    fontwidth%=WINDOW(12):fontheight%=WINDOW(13):windo&=WINDOW(7)
  572.    wm%=PEEKW(windo&+8):Col% = INT((wm%/fontwidth%) / 2)
  573.    PRINT TAB(INT(Col% - (LEN(Text$) / 2)));
  574.    PRINT Text$
  575. END SUB
  576. SUB WordWrap(Text$)
  577.    fontwidth%=WINDOW(12):fontheight%=WINDOW(13):windo&=WINDOW(7)
  578.    wm%=PEEKW(windo&+8):centerseed%=(wm%/fontwidth%)
  579.    WHILE LEN(text$) >= centerseed%-5
  580.       FOR spaced%=(centerseed%-5) TO 1 STEP -1
  581.       IF MID$(text$,spaced%,1)=" " THEN EXIT FOR
  582.       NEXT spaced%
  583.       PRINT LEFT$(text$, spaced%)
  584.       text$ = RIGHT$(text$, (LEN(text$) - spaced%))
  585.    WEND
  586.    PRINT text$
  587. END SUB
  588. SUB TotalTime(TIME)
  589.    SHARED hours%,minutes%,seconds%
  590.    hours%=0:minutes%=0:seconds%=0
  591.    IF (TIME/3600)>1 THEN
  592.       hours%=INT(TIME/3600):TIME= TIME MOD 3600
  593.    END IF
  594.    IF (TIME/60)>1 THEN
  595.       minutes%=INT(TIME/60):seconds%= TIME MOD 60
  596.    END IF
  597.    IF TIME<60 THEN seconds%=TIME
  598. END SUB
  599. SUB Wrong_Sound
  600.    SHARED wrongsound%, WrongIFFs$
  601.    WHILE SAY(0) : SLEEP : WEND
  602.    rand%=INT(RND*wrongsound%)+1
  603.    song$=WrongIFFs$(rand%)
  604.    CALL play_sound(song$)
  605. END SUB
  606. SUB Right_Sound
  607.    SHARED rightsound%, RightIFFs$
  608.    WHILE SAY(0) : SLEEP : WEND
  609.    rand%=INT(RND*rightsound%)+1
  610.    song$=RightIFFs$(rand%)
  611.    CALL play_sound(song$)
  612. END SUB
  613.  
  614. SUB Lookback(most%,b%)
  615.     SHARED question$, answer$, gotit%
  616.     count%=most%
  617.     StartBack:
  618.     CLS
  619.     COLOR 2,3
  620.     PRINT"The current question and answer is:"
  621.     COLOR 1,0
  622.     WordWrap(question$(gotit%(most%)))
  623.     PRINT
  624.     WordWrap(answer$(gotit%(most%)))
  625.     PRINT
  626.     COLOR 2,3
  627.     PRINT"Question";count%-b%+1;"and its answer is:"
  628.     COLOR 1,0
  629.     WordWrap(question$(gotit%(count%)))
  630.     PRINT
  631.     WordWrap(answer$(gotit%(count%)))
  632.     PRINT
  633.     COLOR 2,3
  634.     LineCenter("Press <+> to advance, <-> to go back,")
  635.     LineCenter("or <s> to stop.")
  636.     COLOR 1,0
  637.     LoopBack:
  638.     a$=""
  639.     WHILE a$=""
  640.         a$=INKEY$
  641.     WEND
  642.     IF a$="+" AND count%<most% THEN
  643.         ++count%
  644.         GOTO StartBack
  645.     END IF
  646.     IF a$="-" AND (count%-b%)>0 THEN
  647.         --count%
  648.         GOTO StartBack
  649.     END IF
  650.     IF a$="s" THEN GOTO EndBack
  651.     GOTO LoopBack
  652.     EndBack:
  653. END SUB
  654. SUB parse_sample(f$)
  655. SHARED offset&,samples_per_second&
  656. CONST default_rate=10000&
  657.  OPEN "I",1,f$
  658.  dummy$=INPUT$(8,#1)
  659.  x$=INPUT$(4,#1)
  660.  IF x$="8SVX" THEN
  661.    sample_format$="IFF 8SVX"
  662.    dummy$=INPUT$(8,#1)
  663.    dummy$=INPUT$(12,#1)
  664.    '..get sampling rate bytes
  665.    hi%=ASC(INPUT$(1,#1))  '..high BYTE
  666.    lo%=ASC(INPUT$(1,#1))  '..low BYTE
  667.    samples_per_second&=hi%*256 + lo%
  668.    dummy$=INPUT$(6,#1)
  669.    offset&=40  '..bytes up TO this POINT
  670.    REPEAT
  671.     REPEAT
  672.         x$=INPUT$(1,#1)
  673.         offset&=offset&+1
  674.     UNTIL x$="B" AND NOT EOF(1)
  675.     IF NOT EOF(1) THEN
  676.         body$=INPUT$(3,#1)
  677.         offset&=offset&+3
  678.     END IF
  679.    UNTIL body$="ODY" AND NOT EOF(1)
  680.    IF NOT EOF(1) THEN
  681.     x$=INPUT$(4,#1)  '..skip ####
  682.     offset&=offset&+4
  683.    ELSE
  684.     GOTO parseout
  685.    END IF
  686.    CLOSE 1
  687.  ELSE
  688.    CLOSE 1
  689.    sample_format$="unknown"
  690.    offset&=0
  691.    samples_per_second&=default_rate
  692.  END IF
  693. parseout:
  694. END SUB
  695.  
  696. SUB play_sound(f$)
  697. SHARED offset&,samples_per_second&
  698. CONST maxsample=131070
  699. CONST channel=1
  700. CONST CHIP=0, MAXCHIP=2
  701. DIM   wave_ptr&(100)
  702. OPEN "I",1,f$
  703. sample_size&=LOF(1)
  704. CLOSE 1
  705. IF sample_size&=0 THEN GOTO playout
  706. parse_sample(f$)
  707. buffer&=ALLOC(sample_size&,CHIP) '...sample_size& bytes of CHIP RAM
  708. IF buffer& = NULL THEN
  709.   avail&=FRE(MAXCHIP)  '..max. contiguous CHIP RAM
  710.   PRINT "Largest contiguous CHIP RAM is";avail&;"bytes."
  711.   GOTO playout
  712. END IF
  713. OPEN "I",1,f$
  714. fh&=HANDLE(1)
  715. IF fh&=0 THEN
  716.   PRINT "Can't open ";f$;"."
  717.   GOTO playout
  718. END IF
  719. bytes&=xRead(fh&,buffer&,sample_size&)
  720. CLOSE 1
  721.   per& = 3579546 \ samples_per_second&
  722. sz&=sample_size&-offset&
  723. IF sz& <= maxsample THEN
  724.   WAVE channel,buffer&+offset&,sz&
  725.   dur&=.279365*per&*bytes&/1e6*18.2
  726.   SOUND per&,dur&,,channel
  727. ELSE
  728.   segments&=sz&\maxsample
  729.   buf&=buffer&+offset&
  730.   FOR i&=0 TO segments&
  731.    wave_ptr&(i&)=buf&+maxsample*i&
  732.   NEXT
  733.   FOR i&=0 TO segments&
  734.    IF sz& >= maxsample THEN
  735.       WAVE channel,wave_ptr&(i&),maxsample
  736.       bytes&=maxsample
  737.    ELSE
  738.       WAVE channel,wave_ptr&(i&),sz&
  739.       bytes&=sz&
  740.    END IF
  741.    dur&=.279365*per&*bytes&/1e6*18.2
  742.    SOUND per&,dur&,,channel
  743.    sz&=sz&-maxsample
  744.   NEXT
  745. END IF
  746. playout:
  747. END SUB
  748.  
  749. ending:
  750.    GOSUB CloseMenu
  751.    SYSTEM "assign 80Questions:"
  752. STOP
  753.  
  754.